--- title: "农夫约翰的奶酪块" created: 2025-11-28 tags: - 算法 --- # 农夫约翰的奶酪块 ## 题目 [农夫约翰的奶酪块](https://www.acwing.com/problem/content/6125/) ![[043c0790166badf37cee44b54ff65075_720-9687edf9.png]] ## 思路分析 ![[50b446ecbf8a57e8fd668fddd59efda3_720-cab130c4.png]] ## 代码实现 ```cpp #include>n>>Q; int res=0; while(Q--){ int x,y,z; cin>>x>>y>>z; X[x][y]++; Y[y][z]++; Z[x][z]++; if(X[x][y]>=n) res++; if(Y[y][z]>=n) res++; if(Z[x][z]>=n) res++; cout<